<template>
<div class="page" data-name="person-center">
  <div class="navbar">
    <div class="navbar-inner">
      <div class="left">
      </div>
      <div class="title">中心</div>
      <div class="right">
      </div>
    </div>
  </div>
  <div class="person-header-container">
      		
  </div>
  
  <div class="page-content" style="margin-top:106px;padding-bottom:150px">
  		<div class="card" style="margin:0;">
	  		  <div class="card-footer" style="height:80px;">
			  	<a href="#" class="link color-orange order-status" ><i style="  font-size: 18px;  height: 25px;">6</i><span>浏览记录</span></a>
			  	<a href="#" class="link color-orange order-status" ><i style=" font-size: 18px;   height: 25px;">3</i><span>店铺收藏</span></a>
			  	<a href="#" class="link color-orange order-status" ><i style="  font-size: 18px;  height: 25px;">2</i><span>商品收藏</span></a>
			  </div>
		</div>
      	<div class="card" style="margin-left:0;margin-right:0;">
		  <div class="card-header list" style="padding-top: 0px;padding-bottom: 0px;padding-left:0px;padding-right:0px;">
		  	<ul style="width:100%">
			    <li>
			      <a href="/order/list" class="item-content item-link">
			        <div class="item-inner">
			          <div class="item-title">我的订单</div>
			          <div class="item-after">查看更多订单</div>
			        </div>
			      </a>
			    </li>
			  </ul>
		 </div>
		  <div class="card-footer" style="height:80px;">
		  	<a href="/order/list" class="link color-orange order-status" ><i class="icon f7-icons ios-only">person_fill</i><span>待付款</span></a>
		  	<a href="/order/list" class="link color-orange order-status" ><i class="icon f7-icons ios-only">person_fill<span class="badge color-red">5</span></i><span>待发货</span></a>
		  	<a href="/order/list" class="link color-orange order-status" ><i class="icon f7-icons ios-only">person_fill<span class="badge color-red">5</span></i><span>待收货</span></a>
		  	<a href="/order/list" class="link color-orange order-status"><i class="icon f7-icons ios-only">star_half<span class="badge color-red">5</span></i><span>待评价</span></a>
		  	<a href="/message" class="link color-orange order-status"><i class="icon f7-icons ios-only">person_fill</i><span>售后</span></a>
		  </div>
		</div>
		
		
		
		<div class="list center-product-list-container">
							
	    </div>
		
  </div>
</div>

</template>


<script>

function listCenterProducts(start,pageSize,type){
	 var hasMore = true;
	 var productListResult = [];
 	  var formData= tojsonarray("1");
      app.request({
         url: "js/product-list.json",
         method: 'POST',
         contentType: 'application/json',
         async:false,
         data: formData,
         processData: true,
         headers: {
            Authentication: 'Bearer '+ window.localStorage.token
         },
         success: function (data) {
         	//var r  =JSON.parse(data).r;
       	  var r = JSON.parse(data);
         	if(r.length<pageSize){
        		hasMore = false;
        	}
         	var itemNum = parseInt(r.length/2);
         	var itemModel = r.length%2;
         	for(var i=0;i<itemNum;i++){
         		if(i==0){
         			productListResult.push({item:[r[0],r[1]]});
         		}else{
         			productListResult.push({item:[r[i+1],r[i+2]]});
         		}
         	}
         	if(itemModel!=0){
         		productListResult.push({item:[r[r.length-1]]});
         	}
         },
         error:function(data){
      	   app.preloader.hide();
      	   app.dialog.alert(data.response,function(){
	    	});
        }
      });
       
       var recommendProductListTemplate = $$('#recommendProductListTemplate').html();
       var compiledRecommendProductListTemplate = Template7.compile(recommendProductListTemplate);
       var innerHTML = compiledRecommendProductListTemplate({productList:productListResult});
      
        if(type=='ap'){//添加
       	 $$(".center-product-list-container").append(innerHTML);
        }else if(type=='rw'){
       	 $$(".center-product-list-container").html(innerHTML);
        }else{
      	  	app.dialog.alert("未知数据显示类型["+type+"]");
        }
        
}




  return {
  	on:{
  		 pageInit: function () {
  	        var self = this;
  	        app = self.$app;
  	        var fruits = self.fruits;
  	        var router = self.$router;
  	        
  	      	listCenterProducts(0,10,"ap");
  		 }
  	}
	
  };
</script>
